%module tre
 %{
#include <tre/tre-config.h>
#include <tre/tre.h>
#include <tre/regex.h>

#include <libutf8.h>
 %}
 
%include <tre/tre-config.h>
%include <tre/tre.h>
%include <tre/regex.h>

%inline %{
  void *new_int_as_void_p() {
    return (void*) malloc(sizeof(int));
  }

  void free_void_p(void *p) {
    free( p );
  }

  int void_p_as_int(void *p) {
    return *(int*)p;
  }

  void setlocaleToNothing() {
    setlocale( LC_ALL, "" );
  } 

  int getMB_CUR_MAX() {
    return MB_CUR_MAX;
  }

  int localeIsUTF8() {
    return locale_is_utf8;
  }

%}

/*
%typemap(jni) wchar_t *WSTRING = "jobject"
%typemap(jtype) wchar_t *WSTRING = "String"
%typemap(jstype) wchar_t *WSTRING = "String"

%typemap(in) wchar_t *WSTRING {
  $1 = NULL;
  if( $input != NULL
  const jchar *str = (*jenv)->GetStringChars( env, $input);
#if (sizeof(wchar_t) != sizeof(jchar)
  jint len = (*jenv)->GetStringLength( env, $input );
  wchar_t* str2 = (wchar_t*)malloc((len+1)*sizeof(wchar_t));
  int i;
  for( i = 0; i < len; i++ )
    str2[i] = str[i];
  str2[len] = 0;
  (*jenv)->
 */
